from django import forms
from web import models

class OrderModelForm(forms.ModelForm):
    class Meta:
        model = models.Order
        fields = ['order_id', 'order_date', 'ship_date', 'ship_mode', 'customer_id', 'customer_name', 'segment',
                  'country', 'city', 'state', 'postal_code', 'region', 'product_id', 'category', 'sub_category',
                  'product_name', 'sales']

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for name, field in self.fields.items():
            field.widget.attrs['class'] = 'form-control'
            field.widget.attrs['placeholder'] = '请输入{}'.format(field.label)